#ifndef __BE_MESH__
#define __BE_MESH__

class Mesh;

typedef NamedObjectSet<GLMeshPtr> GLMeshPtrSet;

class Mesh : public NamedObject
{
 public:
  enum
  {
    TRIANGLES,
    FANS,
    STRIPS,
    INVALID_TYPE,
  };

  enum
  {
    VERTEX_COLOR,                      // using data1 as vertex, data2 as color
    VERTEX_COLOR_INTERLEAVE,           // using data1 as vertex/color interleave
    VERTEX_COLOR_INDEXED,              // using data1 as vertex, data2 as color, index as index
    VERTEX_COLOR_INTERLEAVE_INDEXED,   // using data1 as vertex/color interleave, index as index 
    INVALID_FORMAT,
  };

 protected:
  GLfloat *data1;
  GLfloat *data2;
  GLuint  *index;
 
  int type;
  int format;
  int data1_size, data2_size, index_size;

  Mesh();
  Mesh( const Handle & _handle, const String & _name );
  
 public:
  virtual ~Mesh();

  //virtual bool setVertices( int _type, Turple3fArray & _vertices, Turple3iArray & _colors ) = 0;
  //virtual bool setInterleaveVertices(int _type, Turple3fArray & _vertices) = 0;
  virtual bool setIndexedVertices( Turple3fArray & _vertices, Turple1iArray & _index ) = 0;

  friend class OSMesaRender;
};

class GLMesh : public Mesh
{
 public:
  GLMesh();
  GLMesh( const Handle & _handle, const String & _name );
  ~GLMesh();
  
  bool setIndexedVertices( Turple3fArray & _vertices, Turple1iArray & _index );
};


class Mesh2 : public Mesh
{
 public:
  typedef std::vector< Turple<Turple3f, 2> > VertexArray;

 private:
  int size;
  float *data;

 public:
  Mesh2();
  ~Mesh2();

  bool setIndexedVertices( Turple3fArray & _vertices, Turple1iArray & _index );
  void clear();
  void set( VertexArray &_vertexArray );

  friend class OSMesaRender;
};


#endif
